package com.yao.spider.utils;

import java.io.*;

public class FileUtils {
    public static void readByLine() {
        try{
            // 需要读取的文件路径
            String path = "D:\\工作\\二级库\\上海数据\\person_info.json";
            File file = new File(path);

            // 判断文件是否存在
            if (file.isFile() && file.exists()){
                System.out.println("fileExist");
                InputStreamReader read = new InputStreamReader(new FileInputStream(file));
                BufferedReader bufferedReader = new BufferedReader(read);
                String lineText = null;

                // 按行读取文件并打印,如果需要对内容进行操作可以在这里进行
                while((lineText = bufferedReader.readLine())!=null){
                    System.out.println(lineText);
                }
            }else{
                System.out.println("file doesn't exist");
            }
        } catch(IOException e){
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        readByLine();
    }

}
